home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / Peter Lewis (TCPExample) / PNL Libraries / MyAssertions.p < prev    next >
Encoding:
Text File  |  1995-09-04  |  907 b   |  52 lines  |  [TEXT/CWIE]

  1. unit MyAssertions;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types;
  7.  
  8.     procedure Assert (b: boolean);
  9.     procedure AssertValidPtr (p: univ ptr);
  10.     procedure AssertValidPtrNil (p: univ ptr);
  11.     procedure AssertValidHandle (hhhh: univ handle);
  12.     procedure AssertValidHandleNil (hhhh: univ handle);
  13.  
  14. implementation
  15.  
  16.     uses
  17.         Memory;
  18.  
  19.     procedure Assert (b: boolean);
  20.     begin
  21.         if not b then begin
  22.             DebugStr('Assert Failed;sc;hc');
  23.         end;
  24.     end;
  25.  
  26.     procedure AssertValidPtr (p: univ ptr);
  27.     begin
  28.         Assert((p <> nil) & (not odd(ord(p))));
  29.     end;
  30.  
  31.     procedure AssertValidPtrNil (p: univ ptr);
  32.     begin
  33.         if p <> nil then begin
  34.             AssertValidPtr(p);
  35.         end;
  36.     end;
  37.  
  38.     procedure AssertValidHandle (hhhh: univ handle);
  39.     begin
  40.         AssertValidPtr(hhhh);
  41.         AssertValidPtr(hhhh^);
  42.         Assert(RecoverHandle(hhhh^) = hhhh);
  43.     end;
  44.  
  45.     procedure AssertValidHandleNil (hhhh: univ handle);
  46.     begin
  47.         if hhhh <> nil then begin
  48.             AssertValidHandle(hhhh);
  49.         end;
  50.     end;
  51.  
  52. end.